package com.ddone.controller;

import com.ddone.config.DataSourceProperties;
import com.ddone.config.DatasourceConfigProp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ddone
 * @date 2024/3/25-00:02
 */
@RestController
@Slf4j
@EnableConfigurationProperties(DatasourceConfigProp.class)
public class HelloController {

    @Autowired
    private DatasourceConfigProp datasourceConfigProp;

    @Autowired
    private DataSourceProperties dataSourceProperties;


    @GetMapping("/hello")
    public String hello(){
        return "Hello Spring Boot111222333";
    }

    @GetMapping("/prop")
    public String testProp(){
        log.warn("dataSourceProperties = " + dataSourceProperties);
        return "测试SpringBoot 属性注入";
    }

    @GetMapping("/prop-cp")
    public String testPropConfig(){
        log.warn("datasourceConfigProp = " + datasourceConfigProp);
        return "测试SpringBoot 属性批量注入";
    }

}
